<script src="{{ site.assets }}/js/jquery-2.0.3.min.js"></script>
<script src="{{ site.assets }}/js/jquery.imagesloaded.min.js"></script>
<script src="{{ site.assets }}/js/gallery.js"></script>
<script src="{{ site.assets }}/js/jquery.qrcode-0.12.0.min.js"></script>
<script src="{{ site.assets }}/js/toc.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  {% if page.layout == 'post' and site.close_aside %}
        getSize();
        if (myWidth >= 1024) {
          c.click();
          $('#toc.toc-aside').show();
        }
  {% endif %}
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      {% if page.layout == 'post' and page.toc != false and site.toc.aside %}
      $('#toc.toc-aside').css('display', 'none');
      {% endif %}
    }
  });
});
</script>

{% if page.layout == 'post' %}
<script type="text/javascript">
$(document).ready(function(){ 
  $('#toc.toc-aside').toc({
    title: "{{ lang.contents }}",
    showEffect: "none"
  });
  $('#toc.toc-article').toc({
    title: "{{ lang.contents }}",
    showEffect: "show",
    showSpeed: 0
  });
});
</script>
{% endif %}

{% if page.layout == 'post' %}
<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>
{% endif %}

{% if (page.layout == 'post' or page.layout == 'page' or page.layout == 'photo') and !site.jiathis.enable  %}
<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<div class="qrcode clearfix"><span>扫描二维码分享到微信朋友圈</span><a class="qrclose" href="#nothing"></a><strong>Loading...Please wait</strong><img id="qrcode-pic" data-src="http://s.jiathis.com/qrcode.php?url=' + encodedUrl + '"/></div>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);
  
  $('.article-share-qrcode').click(function(){
    var imgSrc = $('#qrcode-pic').attr('data-src');
    $('#qrcode-pic').attr('src', imgSrc);
    $('#qrcode-pic').load(function(){
        $('.qrcode strong').text(' ');
    });
  });
/*
  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      //$('.hoverqrcode').hide();
  });
  */
});   
</script>
{% endif %}

{% if site.duoshuo_shortname %}
<script type="text/javascript">
  var duoshuoQuery = {short_name:"{{ site.duoshuo_shortname }}"};
  (function() {
    var ds = document.createElement('script');
    ds.type = 'text/javascript';ds.async = true;
    ds.src = '//static.duoshuo.com/embed.js';
    ds.charset = 'UTF-8';
    (document.getElementsByTagName('head')[0] 
    || document.getElementsByTagName('body')[0]).appendChild(ds);
  })();
</script> 
{% endif %}
{% if site.disqus_shortname %}
<script type="text/javascript">
var disqus_shortname = '{{ site.disqus_shortname }}';
(function(){
  var dsq = document.createElement('script');
  dsq.type = 'text/javascript';
  dsq.async = true;
  dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
(function(){
  var dsq = document.createElement('script');
  dsq.type = 'text/javascript';
  dsq.async = true;
  dsq.src = '//' + disqus_shortname + '.disqus.com/count.js';
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
{% endif %}

<!--
{% if page.layout == 'tags' or page.layout == 'categories' %}
<script type="text/javascript">
$(document).ready(function(){ 
  var list    = $('.archive-title a'),
      box     = $('.all-list-box'),
      first   = $('.archive-title a:first-of-type');
      box.load(first.attr('data-src').toString()+' #archive-page');
      first.addClass('current');
  list.each(function(){
    $(this).click(function(){
      var listSrc=$(this).attr('data-src').toString()+' #archive-page';
      box.load(listSrc);
      list.removeClass('current');
      $(this).addClass('current');
     });  
    });
  }); 
</script>
{% endif %}
-->

{% if page.layout == 'archives' or page.layout == 'categories' or page.layout == 'tags' %}
<script type="text/javascript">
$(document).ready(function(){
    var show_post = function(anchor) {
        $(".post").hide();
        var cls = anchor.substr(1);
        $("." + cls).show();
        $(".archive-folder").text(cls);
    }
    if (document.location.hash) {
        show_post(document.location.hash);
    }
    $('a[href*=#]').click(function() {
        if (this.hash) {
            show_post(this.hash);
        }
    });
    
});
</script>
{% endif %}

{% if site.fancybox %}
<link rel="stylesheet" href="{{ site.assets }}/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="{{ site.assets }}/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      if ($(this).hasClass('emoji')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>
{% endif %}

<!-- Analytics Begin -->
{% include _partial/analytics.html %}
<!-- Analytics End -->

<!-- Totop Begin -->
{% include _partial/totop.html %}
<!-- Totop End -->

<!-- MathJax Begin -->
{% include _partial/mathjax.html %}
<!-- MathJax End -->

<!-- Tiny_search Begin -->
{% include _partial/tinysou_search.html %}
<!-- Tiny_search End -->